package com.ludomancy.archeologyrpg.entities;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

import com.ludomancy.archeologyrpg.GameTheme;
import com.ludomancy.archeologyrpg.Entity;
import com.ludomancy.archeologyrpg.Game;

public class Dwelling extends Entity
{
	private int oxygenMax = Game.discretize(2000); // 1 unit each 2 seconds
	private int oxygenTime = 0;
	private int oxygenPack = 20; // 20 % oxygen increase
	private int oxygenStored = 10;
	
	public Dwelling(Point p)
	{
		super(p);
	}

	public void paint(Graphics g, int x, int y)
	{
		paintDefaultIcon(g, DWELLING, x, y);
	}
	public void update(boolean running, boolean activated)
	{
		if(running)
		{
			if(activated)
			{
				
				if(oxygenStored > 0)
				{
					oxygenTime++;
					if(oxygenTime == oxygenMax)
					{
						oxygenTime = 0;
						Game.game.rocket.addOxygen(oxygenPack);
						oxygenStored--;
					}
				}
			}
		}
	}

	public void paintInfo(Graphics g)
	{
		g.setColor(Color.BLUE);
		g.setFont(GameTheme.theme.tinyFont);
		if(oxygenTime > 0)
		{
			GameTheme.theme.paintBar(g, px, py+Game.ENTITY_TILE_SIZE, oxygenTime, oxygenMax);
		}
	}

	public String getActionVerb()
	{
		return "Extract O2";
	}
}
